<template>
  <div class="no-finish">
    <div v-if="showNoFinish">
      <div class="search-box flex">
        id:
        <el-input v-model="inputId" placeholder="请输入内容"></el-input>
        站点名称:
        <el-input v-model="inputZd" placeholder="请输入内容"></el-input>
        内容关键字:
        <el-input v-model="inputKey" placeholder="请输入内容"></el-input>
        <button class="search-btn" @click="searchId">搜索</button>
      </div>

      <div class="table">
        <div class="table-title">
          <span
            class="el-icon-warning-outline"
            style="color: rgb(255, 112, 3)"
          ></span>
          超时未完结
          <span>(三个工作日内未完结)</span>
        </div>
        <el-table
          :data="delayRecord"
          @cell-click="cellClick"
          style="width: 100%"
        >
          <el-table-column
            style="
              font-size: 16px !important;
              font-weight: 700 !important;
              color: #555555;
            "
            label="排期信息"
            align="center"
          >
            <el-table-column
              type="selection"
              prop="name"
              label="选择"
              width="60"
              align="center"
            >
            </el-table-column>
            <el-table-column prop="id" label="id" width="100" align="center">
            </el-table-column>
            <el-table-column
              prop="cityname"
              label="站点名称"
              width="100"
              align="center"
            >
            </el-table-column>
            <el-table-column prop="url" label="网址" align="center">
            </el-table-column>
            <el-table-column
              prop="feed_content"
              label="反馈内容"
              align="center"
            >
            </el-table-column>
            <el-table-column prop="add_time" label="时间" align="center">
            </el-table-column>
            <el-table-column
              prop="delayDate"
              label="距今"
              width="80"
              align="center"
            >
            </el-table-column>
          </el-table-column>
          <el-table-column
            prop="currentFollow"
            label="当前跟进负责人"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="statusType"
            label="状态"
            width="90"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="handle"
            label="操作"
            width="240"
            align="center"
          >
            <template slot-scope="scope">
              <el-button
                @click="openDialog(scope.row, 1)"
                style="color: #333"
                type="text"
                >【审核】</el-button
              >
              <el-button
                type="text"
                style="color: #333"
                @click="openDialog(scope.row, 2)"
                >【查看】</el-button
              >
              <el-button
                type="text"
                style="color: #333"
                @click="openDialog(scope.row, 3)"
                >【转接】</el-button
              >
            </template>
          </el-table-column>
        </el-table>
      </div>

      <div class="table">
        <div class="table-title">
          <span
            class="el-icon-warning-outline"
            style="color: rgb(255, 21, 21)"
          ></span>
          催促未完结
          <span>（用户问题较紧急，请尽快处理）</span>
        </div>
        <el-table
          :data="urgentRecord"
          style="width: 100%"
          @cell-click="cellClick"
        >
          <el-table-column label="排期信息" align="center">
            <el-table-column
              type="selection"
              prop="name"
              label="选择"
              width="60"
              align="center"
            >
            </el-table-column>
            <el-table-column prop="id" label="id" width="100" align="center">
            </el-table-column>
            <el-table-column
              prop="cityname"
              label="站点名称"
              width="100"
              align="center"
            >
            </el-table-column>
            <el-table-column prop="url" label="网址" align="center">
            </el-table-column>
            <el-table-column
              prop="feed_content"
              label="反馈内容"
              align="center"
            >
            </el-table-column>
            <el-table-column prop="add_time" label="时间" align="center">
            </el-table-column>
            <el-table-column
              prop="delayDate"
              label="距今"
              width="80"
              align="center"
            >
            </el-table-column>
          </el-table-column>
          <el-table-column
            prop="currentFollow"
            label="当前跟进负责人"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="statusType"
            label="状态"
            width="90"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="handle"
            label="操作"
            width="240"
            align="center"
          >
            <template slot-scope="scope">
              <el-button
                @click="openDialog(scope.row, 1)"
                style="color: #333"
                type="text"
                >【审核】</el-button
              >
              <el-button
                type="text"
                style="color: #333"
                @click="openDialog(scope.row, 2)"
                >【查看】</el-button
              >
              <el-button
                type="text"
                style="color: #333"
                @click="openDialog(scope.row, 3)"
                >【转接】</el-button
              >
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="table">
        <div class="table-title">
          <span
            class="el-icon-warning-outline"
            style="color: rgb(63, 209, 211)"
          ></span>
          普通未完结
        </div>
        <el-table
          :data="commonRecord"
          @cell-click="cellClick"
          style="width: 100%"
        >
          <el-table-column label="排期信息" align="center">
            <el-table-column
              type="selection"
              prop="name"
              label="选择"
              width="60"
              align="center"
            >
            </el-table-column>
            <el-table-column prop="id" label="id" width="100" align="center">
            </el-table-column>
            <el-table-column
              prop="cityname"
              label="站点名称"
              width="100"
              align="center"
            >
            </el-table-column>
            <el-table-column prop="url" label="网址" align="center">
            </el-table-column>
            <el-table-column
              prop="feed_content"
              label="反馈内容"
              align="center"
            >
            </el-table-column>
            <el-table-column prop="add_time" label="时间" align="center">
            </el-table-column>
            <el-table-column
              prop="delayDate"
              label="距今"
              width="80"
              align="center"
            >
            </el-table-column>
          </el-table-column>
          <el-table-column
            prop="currentFollow"
            label="当前跟进负责人"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="statusType"
            label="状态"
            width="90"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="handle"
            label="操作"
            width="240"
            align="center"
          >
            <template slot-scope="scope">
              <el-button
                @click="openDialog(scope.row, 1)"
                style="color: #333"
                type="text"
                >【审核】</el-button
              >
              <el-button
                type="text"
                style="color: #333"
                @click="openDialog(scope.row, 2)"
                >【查看】</el-button
              >
              <el-button
                type="text"
                style="color: #333"
                @click="openDialog(scope.row, 3)"
                >【转接】</el-button
              >
            </template>
          </el-table-column>
        </el-table>
      </div>

      <!-- 弹窗 -->
      <el-dialog
        custom-class="dia-check"
        :visible.sync="dialogFormVisible1"
        @close="closeCheck"
        width="644px"
      >
        <div slot="title" class="dialog-footer">
          <div class="dia-title flex align-center">
            <img src="../../assets/images/check-dia.png" alt="" />审核
          </div>
        </div>
        <div class="dia-body">
          <div>
            <span class="db-title flex flex-end">id:</span>
            <span>{{ form.id }}</span>
          </div>
          <div>
            <span class="db-title flex flex-end">网址:</span>
            <span class="cursor" style="color: #37c1c3" @click="openUrl(form.url)">{{ form.url }}</span>
          </div>
          <div style="color: #ff1717; margin: 0 0 10px 70px">
            （注:若页面内容存在问题，必须先修改页面内容再完善下面信息）
          </div>
          <div>
            <span class="db-title flex flex-end">反馈内容:</span>

            <span>
              {{ form.feed_content }}
            </span>
          </div>
          <div>
            <span class="db-title flex flex-end">联系电话:</span
            ><span>{{ form.tel }}</span>
          </div>
          <div>
            <span class="db-title flex flex-end">回复用户:</span
            ><el-input
              type="textarea"
              resize="none"
              placeholder="请输入内容"
              v-model="ex_reply"
            ></el-input>
            <span class="must">选填</span>
          </div>
          <div>
            <span class="db-title flex flex-end">备注:</span
            ><el-input
              type="textarea"
              resize="none"
              placeholder="请输入内容"
              v-model="ex_beizhu"
            ></el-input>
            <span class="must">选填</span>
          </div>
          <div style="display: flex">
            <span class="db-title flex flex-end">常用回复:</span>
            <div style="width: 440px">
              <div style="margin-bottom: 10px" @click="copy(1)">
                非常抱歉带给您不好的体验，我们对您提供的问题已进行整改。如需进一步的需求沟通，可通过我们的人工热线4009999087与我们联系。再次感谢您的反馈，我们将一直完善我们的服务，给您带来更好的体验，祝您生活愉快~
              </div>
              <div @click="copy(2)">
                非常抱歉带给您不好的体验，由于我们对您提供的问题了解不够清晰。可通过我们的人工热线4009999087进一步沟通，期待您的来电。再次感谢您的反馈，我们将一直完善我们的服务，给您带来更好的体验，祝您生活愉快~
              </div>
            </div>
          </div>
        </div>
        <div slot="footer" class="dialog-footer flex just-center">
          <el-button type="primary" @click="sendExamine">确 定</el-button>
        </div>
      </el-dialog>

      <el-dialog
        custom-class="dia-watch"
        :visible.sync="dialogFormVisible2"
        width="644px"
      >
        <div slot="title" class="dialog-footer">
          <div class="dia-title flex align-center">
            <img src="../../assets/images/watch-dia.png" alt="" />查看
          </div>
        </div>
        <div class="dia-body">
          <div>
            <span class="db-title flex flex-end">id:</span>
            <span>{{ form.id }}</span>
          </div>
          <div>
            <span class="db-title flex flex-end">网址:</span>
            <span class="cursor" style="color: #888" @click="openUrl(form.url)">{{ form.url }}</span>
          </div>
          <div style="color: #ff1717; margin: 0 0 10px 70px">
            （注:若页面内容存在问题，必须先修改页面内容再完善下面信息）
          </div>
          <div>
            <span class="db-title flex flex-end">反馈内容:</span>

            <span>
              {{ form.feed_content }}
            </span>
          </div>
          <div>
            <span class="db-title flex flex-end">联系电话:</span
            ><span>{{ form.tel }}</span>
          </div>
          <div>
            <span class="db-title flex flex-end">回复用户:</span
            ><el-input
              type="textarea"
              :disabled="true"
              resize="none"
              v-model="form.examine_content"
            ></el-input>
            <span class="must">选填</span>
          </div>
          <div>
            <span class="db-title flex flex-end">备注:</span
            ><el-input
              type="textarea"
              resize="none"
              v-model="ex_beizhu"
              :disabled="true"
            ></el-input>
            <span class="must">选填</span>
          </div>
          <div>
            <span class="db-title flex flex-end">常用回复:</span>

            <span
              >非常抱歉带给您不好的体验，您可通过电话0755-82180123与我们联系，再次感谢您的反馈，我们将一直完善我们的服务，给您带来更好的体验，祝您生活愉快~</span
            >
          </div>
        </div>
        <div slot="footer" class="dialog-footer flex just-center">
          <el-button type="primary" @click="dialogFormVisible2 = false"
            >确 定</el-button
          >
        </div>
      </el-dialog>

      <el-dialog
        custom-class="dia-zhuanjie"
        :visible.sync="dialogFormVisible3"
        width="350px"
        @close="closeTransform"
      >
        <div slot="title" class="dialog-footer">
          <div class="dia-title flex align-center">
            <img src="../../assets/images/zhuanjie.png" alt="" />转接跟进负责人
          </div>
        </div>
        <div @click="closeNameList">
          <el-form :model="form">
            <el-form-item label="发起人:">
              <el-input
                v-model="faqi"
                :disabled="true"
                @input="inputFaqi(faqi, 1)"
                autocomplete="off"
              ></el-input>
              <span
                style="font-size: 12px; color: #00a9ab"
                v-show="
                  !form.follow_user1 && !form.follow_user2 && !form.examine_user
                "
                >当前跟进负责人</span
              >
              <div v-show="nameList.length !== 0" class="name-ul">
                <div
                  v-for="(item, index) in nameList"
                  :key="index"
                  @click="chooseName(item.realname, 1)"
                >
                  {{ item.realname }}
                </div>
              </div>
            </el-form-item>
            <el-form-item label="跟进人:">
              <el-input
                id="input2"
                v-model="follow_user1"
                :disabled="disable3"
                @input="inputFaqi(follow_user1, 2)"
              >
              </el-input>
              <span
                style="font-size: 12px; color: #00a9ab"
                v-show="
                  form.follow_user1 && !form.follow_user2 && !form.examine_user
                "
                >当前跟进负责人</span
              >
              <div v-show="nameList2.length !== 0" class="name-ul">
                <div
                  v-for="(item, index) in nameList2"
                  :key="index"
                  @click="chooseName(item.realname, 2)"
                >
                  {{ item.realname }}
                </div>
              </div>
            </el-form-item>
            <el-form-item label="跟进人:">
              <el-input
                id="input2"
                v-model="follow_user2"
                :disabled="disable4"
                @input="inputFaqi(follow_user2, 3)"
                placeholder="搜索"
              >
              </el-input>
              <span
                style="font-size: 12px; color: #00a9ab"
                v-show="form.follow_user2 && !form.examine_user"
                >当前跟进负责人</span
              >
              <div v-show="nameList3.length !== 0" class="name-ul">
                <div
                  v-for="(item, index) in nameList3"
                  :key="index"
                  @click="chooseName(item.realname, 3)"
                >
                  {{ item.realname }}
                </div>
              </div>
            </el-form-item>
            <el-form-item label="审核人:">
              <el-input
                v-model="examine_user"
                @input="inputFaqi(examine_user, 4)"
                placeholder="夏雨 苏苏"
                :disabled="disable5"
              >
              </el-input>
              <span
                style="font-size: 12px; color: #00a9ab"
                v-show="form.examine_user"
                >当前跟进负责人</span
              >
              <div v-show="nameList4.length !== 0" class="name-ul">
                <div
                  v-for="(item, index) in nameList4"
                  :key="index"
                  @click="chooseName(item.realname, 4)"
                >
                  {{ item.realname }}
                </div>
              </div>
            </el-form-item>
          </el-form>
        </div>
        <div slot="footer" class="dialog-footer flex just-center">
          <el-button type="primary" @click="sendTransform">确 定</el-button>
        </div>
      </el-dialog>

      <el-dialog
        custom-class="dia-zhuanjie state"
        :visible.sync="dialogFormVisible4"
        width="422px"
      >
        <div slot="title" class="dialog-footer">
          <div class="dia-title flex align-center">
            <img src="../../assets/images/state.png" alt="" />审核状态
          </div>
        </div>
        <div class="dia-body">
          <div>
            <span class="flex flex-end">审核状态:</span>
            <el-dropdown @command="commands">
              <span class="el-dropdown-link">
                {{ stateValue
                }}<i class="el-icon-arrow-down el-icon--right"></i>
              </span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item command="未审核">未审核</el-dropdown-item>
                <el-dropdown-item command="审核中">审核中</el-dropdown-item>
                <el-dropdown-item command="已审核">已审核</el-dropdown-item>
                <el-dropdown-item command="退回">退回</el-dropdown-item>
                <el-dropdown-item command="已完结">已完结</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </div>
          <div>
            <span class="flex flex-end">备注:</span>
            <el-input
              class="beizhu"
              type="textarea"
              resize="none"
              v-model="ex_note"
              autocomplete="off"
            ></el-input>
            <div style="margin-top: 70px">选填</div>
          </div>
        </div>
        <div slot="footer" class="dialog-footer flex just-center">
          <el-button type="primary" @click="statusDefine">确 定</el-button>
        </div>
      </el-dialog>
      <!-- /弹窗 -->
    </div>
    <div
      v-else
      style="
        width: 300px;
        text-align: center;
        margin: 200px auto;
        font-size: 30px;
      "
    >
      <span class="el-icon-loading" v-if="!commonRecord"></span>
      <span v-else>暂无权限</span>
    </div>
  </div>
</template>

<script>
import { get, post } from "../../axios/request";
export default {
  data() {
    return {
      inputId: "",
      inputZd: "",
      inputKey: "",
      form: {},
      stateValue: "",
      dialogFormVisible1: false,
      dialogFormVisible2: false,
      dialogFormVisible3: false,
      disable3: false,
      disable4: false,
      disable5: false,
      dialogFormVisible4: false,
      zhuanJie: "",
      textarea2: "",
      commonRecord: [],
      delayRecord: [],
      urgentRecord: [],
      timeout: null,
      nameList: [],
      nameList2: [],
      nameList3: [],
      nameList4: [],
      faqi: "搜索",
      ex_note: "",
      stateValueNum: "",
      whiteName: [
        "苏苏",
        "夏雨",
        "搜索",
        "小柯",
        "炎豪",
        "小阮",
        "鹏子",
        "产品通用",
        "56",
        "伍六",
        "admin",
        "sousuo",
      ],
      ex_reply: "",
      ex_beizhu: "",
      reg1: "",
      reg2: "",
      examine_user: "",
      follow_user1: "",
      follow_user2: "",
      showNoFinish: false,
      quickReply1:
        "非常抱歉带给您不好的体验，我们对您提供的问题已进行整改。如需进一步的需求沟通，可通过我们的人工热线4009999087与我们联系。再次感谢您的反馈，我们将一直完善我们的服务，给您带来更好的体验，祝您生活愉快~",
      quickReply2:
        "非常抱歉带给您不好的体验，由于我们对您提供的问题了解不够清晰。可通过我们的人工热线4009999087进一步沟通，期待您的来电。再次感谢您的反馈，我们将一直完善我们的服务，给您带来更好的体验，祝您生活愉快~",
    };
  },

  created() {
    if (this.$route.query.username) {
      let username = this.$route.query.username;
      localStorage.setItem("userName", username);
    }

    this.getFollow(1);
    this.getFollow();
    this.getFollow(11);
    this.getCommonRecord();
    this.getUrgentRecord();
    this.getDelayRecord();
  },

  methods: {
    getFollow(num) {
      let username = decodeURI(localStorage.getItem("userName"));
      let data = {
        follow_user1: username,
        status: num == 11 ? "" : num,
        is_urgent: num == 11 ? "1" : "",
      };
      get("index.php?ac=list&page=1", data).then((res) => {
        if (res.data.code === -2) {
          window.location.replace("://houtai.wh.bendibao.com/login.php")
        } else if (res.data.code === 0) {
          if (res.data.data.length !== 0) {
            this.whiteName.push(username);
            this.whiteName.forEach((val) => {
              if (val == username) {
                this.showNoFinish = true;
              }
            });
          } else {
            this.whiteName.forEach((val) => {
              if (val == username) {
                this.showNoFinish = true;
              }
            });
          }
        }
      });
    },
    /**
     * 获取普通未完结
     */
    getCommonRecord() {
      let data = {
        status: "1",
        id: this.inputId,
        cityname: this.inputZd,
        keywords: this.inputKey,
      };
      get(`index.php?ac=list&page=1&size=1000`, data).then((res) => {
        if (res.data.code === 0) {
            if (res.data.count !== 0) {
          if (Array.isArray(res.data.data)) {
            this.commonRecord = res.data.data;
          } else {
            this.commonRecord = [];
            this.commonRecord.push(res.data.data);
          }
          this.commonRecord.forEach((val) => {
            let statusType = this.tranStatus(val.status);
            val["statusType"] = statusType;

            if (val.follow_user1 && !val.follow_user2 && !val.examine_user) {
              val["currentFollow"] = val.follow_user1;
              // val["statusType"] = "审核中";
            } else if (val.follow_user2 && !val.examine_user) {
              val["currentFollow"] = val.follow_user2;
              // val["statusType"] = "审核中";
            } else if (val.examine_user) {
              val["currentFollow"] = val.examine_user;
              // val["statusType"] = "审核中";
            }
            let delayDate = this.calculate(val.add_time);
            val["delayDate"] = delayDate + "天";
          });
        }
        }
      });
    },

    /**
     * 获取催促未完结
     */
    getUrgentRecord() {
      let data = {
        is_urgent: "1",
        id: this.inputId,
        cityname: this.inputZd,
        keywords: this.inputKey,
      };
      get(`index.php?ac=list&page=1&size=1000`, data).then((res) => {
        if (res.data.code === -2) {
          return
        }
        if (res.data.count !== 0) {
          if (Array.isArray(res.data.data)) {
            this.urgentRecord = res.data.data;
          } else {
            this.urgentRecord = [];
            this.urgentRecord.push(res.data.data);
          }
          this.urgentRecord.forEach((val) => {
            let statusType = this.tranStatus(val.status);
            val["statusType"] = statusType;
            if (val.follow_user1 && !val.follow_user2 && !val.examine_user) {
              val["currentFollow"] = val.follow_user1;
              // val["statusType"] = "审核中";
            } else if (val.follow_user2 && !val.examine_user) {
              val["currentFollow"] = val.follow_user2;
              // val["statusType"] = "审核中";
            } else if (val.examine_user) {
              val["currentFollow"] = val.examine_user;
              // val["statusType"] = "审核中";
            }
            let delayDate = this.calculate(val.add_time);
            val["delayDate"] = delayDate + "天";
          });
        }
      });
    },

    /**
     * 获取超时未完结
     */
    getDelayRecord() {
      let data = {
        id: this.inputId,
        cityname: this.inputZd,
        keywords: this.inputKey,
      };
      get(`index.php?ac=list&page=1&size=1000`, data).then((res) => {
        if (res.data.code === -2) {
          return
        }
        if (res.data.count !== 0) {
          if (Array.isArray(res.data.data)) {
            this.delayRecord = res.data.data;
          } else {
            this.delayRecord = [];
            this.delayRecord.push(res.data.data);
          }
          this.delayRecord.forEach((val) => {
            let statusType = this.tranStatus(val.status);
            val["statusType"] = statusType;
            if (val.follow_user1 && !val.follow_user2 && !val.examine_user) {
              val["currentFollow"] = val.follow_user1;
              // val["statusType"] = "审核中";
            } else if (val.follow_user2 && !val.examine_user) {
              val["currentFollow"] = val.follow_user2;
              // val["statusType"] = "审核中";
            } else if (val.examine_user) {
              val["currentFollow"] = val.examine_user;
              // val["statusType"] = "审核中";
            }
            let delayDate = this.calculate(val.add_time);
            val["delayDate"] = delayDate + "天";
          });
        }
      });
    },

    /**
     * 计算延期时间
     */
    calculate(addTime) {
      let date = new Date(addTime);
      let now = new Date();
      let delta = (now - date) / 1000; // 秒差值

      // 把差值换算成:  天时分秒
      let days = parseInt(delta / 3600 / 24) + "";
      return days;
    },

    /**
     * 转换状态
     */
    tranStatus(status) {
      if (status == 1) {
        return "未审核";
      } else if (status == 2) {
        return "审核中";
      } else if (status == 3) {
        return "退回";
      } else if (status == 4) {
        return "已完结";
      } else if (status == 7) {
        return "已审核";
      }
    },

    /**
     * 勾选框事件
     */
    choose1(val) {},
    choose2(val) {},
    choose3(val) {},

    /**
     * 打开弹窗
     */
    openDialog(val, num) {
      this.form = JSON.parse(JSON.stringify(val));
      if (num == 1) {
        this.ex_beizhu = this.form.remake;
        this.dialogFormVisible1 = true;
      } else if (num == 3) {
        this.examine_user = this.form.examine_user;
        this.follow_user1 = this.form.follow_user1;
        this.follow_user2 = this.form.follow_user2;
        if (this.form.follow_user1 !== "" || this.form.follow_user2 !== "") {
          this.disable3 = true;
        }
        if (this.form.follow_user2 !== "") {
          this.disable4 = true;
          this.disable3 = true;
        }
        if (this.form.examine_user !== "") {
          this.disable5 = true;
          this.disable3 = true;
          this.disable4 = true;
        }
        this.dialogFormVisible3 = true;
      } else if (num == 2) {
        this.ex_beizhu = this.form.remake;
        this.dialogFormVisible2 = true;
      }
    },

    /**
     * 键入监听事件
     */
    inputFaqi(name, num) {
      if (name !== "") {
        if (num == 1) {
          this.debounce(this.searchFaqi, 500);
        } else if (num == 2) {
          this.debounce(this.searchGj1, 500);
        } else if (num == 3) {
          this.debounce(this.searchGj2, 500);
        } else if (num == 4) {
          this.debounce(this.searchChecker, 500);
        }
      } else {
        this.nameList = [];
        this.nameList2 = [];
        this.nameList3 = [];
        this.nameList4 = [];
      }
    },

    /**
     * 选中人名
     */
    chooseName(name, num) {
      if (num == 1) {
        this.form.follow_user1 = name;
        this.nameList = [];
      } else if (num == 2) {
        this.follow_user1 = name;
        this.nameList2 = [];
      } else if (num == 3) {
        this.follow_user2 = name;
        this.nameList3 = [];
      } else if (num == 4) {
        this.examine_user = name;
        this.nameList4 = [];
      }
    },

    /**
     * 发起人查询
     */
    searchFaqi() {
      if (this.form.follow_user1 == "") {
        return;
      }
      get(
        `crmbdb/feedback/api.php?ac=getUser&citysite=crm&name=${this.form.follow_user1}`
      ).then((res) => {
        if (res.data.data.length !== 0) {
          this.nameList = res.data.data;
          // this.form.name = res.data.data[0].realname;
        } else {
          // this.form.name = "";
        }
      });
    },

    /**
     * 跟进人1查询
     */
    searchGj1() {
      if (this.follow_user1 == "") {
        return;
      }
      get(
        `crmbdb/feedback/api.php?ac=getUser&citysite=crm&name=${this.follow_user1}`
      ).then((res) => {
        if (res.data.data.length !== 0) {
          this.nameList2 = res.data.data;
          // this.form.follow_user1 = res.data.data[0].realname;
        } else {
          // this.form.follow_user1 = "";
        }
      });
    },

    /**
     * 跟进人2查询
     */
    searchGj2() {
      if (this.follow_user2 == "") {
        return;
      }
      get(
        `crmbdb/feedback/api.php?ac=getUser&citysite=crm&name=${this.follow_user2}`
      ).then((res) => {
        if (res.data.data.length !== 0) {
          this.nameList3 = res.data.data;
          // this.form.region2 = res.data.data[0].realname;
        } else {
          // this.form.region2 = "";
        }
      });
    },

    /**
     * 审核人查询
     */
    searchChecker() {
      if (this.form.examine_user == "") {
        return;
      }
      get(
        `crmbdb/feedback/api.php?ac=getUser&citysite=crm&name=${this.examine_user}`
      ).then((res) => {
        if (res.data.data.length !== 0) {
          this.nameList4 = res.data.data;
          // this.form.examine = res.data.data[0].realname;
        } else {
          // this.form.examine = "";
        }
      });
    },
    /**
     * 关闭名字列表
     */
    closeNameList() {
      this.nameList = [];
      this.nameList2 = [];
      this.nameList3 = [];
      this.nameList4 = [];
    },
    /**
     * 防抖
     */
    debounce(func, wait) {
      if (this.timeout) clearTimeout(this.timeout);
      this.timeout = setTimeout(() => {
        func();
      }, wait);
    },

    /**
     * 转接跟进人确认按钮事件
     */
    sendTransform() {
      let data = {
        ac: "trans_user",
        id: this.form.id * 1,
        follow_user1: this.follow_user1,
        follow_user2: this.follow_user2,
        examine_user: this.examine_user,
        add_user: this.faqi,
      };
      post(`index.php`, data).then((res) => {
        // this.getCommonRecord();
        // this.getUrgentRecord();
        // this.getDelayRecord();
        let datas = {
          id: this.form.id * 1,
          status: 2,
          examine_note: this.ex_note,
          ac: "examine_status",
        };
        post("index.php", datas).then((res) => {
          this.getCommonRecord();
          this.getUrgentRecord();
          this.getDelayRecord();
        });
        this.dialogFormVisible3 = false;
      });
    },

    /**
     * 关闭转接人的弹窗回调事件
     */
    closeTransform() {
      this.form.follow_user1 = "";
      this.reg1 = "";
      this.reg2 = "";
      this.form.examine_user = "";
      this.nameList = [];
      this.nameList2 = [];
      this.nameList3 = [];
      this.nameList4 = [];
      this.disable3 = false;
      this.disable4 = false;
      this.disable5 = false;
    },

    /**
     * 点击状态事件
     */
    cellClick(row, col, cell, e) {
      let username = decodeURI(localStorage.getItem("userName"));
      if (col.label == "状态" && username == row.examine_user) {
        this.form = JSON.parse(JSON.stringify(row));
        this.stateValue = row.statusType;
        this.dialogFormVisible4 = true;
      }
    },

    /**
     * 审核状态选中更换事件
     */
    commands(val) {
      this.stateValue = val;
    },

    /**
     * 审核状态确认事件
     */
    statusDefine() {
      if (this.stateValue == "审核中") {
        this.stateValueNum = 2;
      } else if (this.stateValue == "退回") {
        this.stateValueNum = 3;
      } else if (this.stateValue == "已完结") {
        this.stateValueNum = 4;
      } else if (this.stateValue == "未审核") {
        this.stateValueNum = 1;
      } else if (this.stateValue == "已审核") {
        this.stateValueNum = 7;
      }
      let data = {
        id: this.form.id * 1,
        status: this.stateValueNum,
        examine_note: this.ex_note,
        ac: "examine_status",
      };
      post("index.php", data).then((res) => {
        this.getCommonRecord();
        this.getUrgentRecord();
        this.getDelayRecord();
      });
      this.stateValue = "";
      this.ex_note = "";
      this.dialogFormVisible4 = false;
    },

    /**
     * 审核弹窗确认事件
     */
    sendExamine() {
      let data = {
        ac: "examine",
        id: this.form.id * 1,
        examine_content: this.ex_reply,
        remake: this.ex_beizhu,
      };
      post("index.php", data).then((res) => {
        this.getCommonRecord();
        this.getUrgentRecord();
        this.getDelayRecord();
        this.dialogFormVisible1 = false;
        this.ex_reply = "";
        this.ex_beizhu = "";
      });
    },

    closeCheck() {
      this.ex_reply = "";
      this.ex_beizhu = "";
    },

    /**
     * 顶部搜索事件
     */
    searchId() {
      let data = {
        status: "4",
        id: this.inputId,
        cityname: this.inputZd,
        keywords: this.inputKey,
      };
      this.getCommonRecord();
      this.getUrgentRecord();
      this.getDelayRecord();
    },

    /**
     * 快捷回复
     */
    copy(num) {
      if (num == 1) {
        this.ex_reply = this.quickReply1;
      } else if (num == 2) {
        this.ex_reply = this.quickReply2;
      }
    },

    openUrl(url){
      window.open(url)
    },
  },
};
</script>

<style lang="stylus" scoped>
@import './noFinish.css';

.el-form-item__content {
  position: relative;
}

.name-ul {
  position: absolute;
  height: 160px;
  overflow-y: auto;
  z-index: 99;
  left: 58px;
  bottom: -152px;
  width: 110px;
  background-color: #E2E2E2;
  color: #333;
}

.name-ul div:hover {
  background-color: #EDEDED;
}
</style>